package utils

import (
	"bufio"
	"os"
	"strings"
)

func ReadByLine(txtPath string) []string {

	strArr := *new([]string)
	txt, _ := os.Open(txtPath)
	defer txt.Close()
	reader := bufio.NewReader(txt)
	for true {
		line, _, _ := reader.ReadLine()
		if len(line) == 0 {
			break
		}
		strArr = append(strArr, string(line))
	}
	return strArr
}

func GetFileNameAndExt(fileFullName string) (name string, ext string) {
	i := strings.LastIndexByte(fileFullName, '.')
	name = fileFullName[0:i]
	ext = fileFullName[i+1:]
	return name, ext
}
